package reviewd

import (
	"time"

	creviewd "gogs.xiaoyuanjijiehao.com/antlinker/antcms/core/reviewd"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/ddd"
)

// @collname 审核集合(i_review)
type collReview struct {
	ReviewID   string    `bson:"_id" `
	TargetType int       `bson:"targetType"` //审核目标类型 1 信息 2 评论
	TargetID   string    `bson:"targetID"`   //审核目标编号
	Reviewer   string    `bson:"reviewer"`   //审核人
	Reason     string    `bson:"reason"`     //审核理由
	Result     bool      `bson:"result"`     //审核结果 true 审核通过 false 审核未通过
	ReviewTime time.Time `bson:"reviewTime"` //审核时间
}

func (c collReview) CollID() string {
	return c.ReviewID
}
func (collReview) CollName() string {
	return collNameReview
}

func (c *collReview) FullDesc(e creviewd.ReviewDesc) {
	c.TargetType = e.TargetType
	c.TargetID = e.TargetID
	c.Reviewer = e.Reviewer
	c.Reason = e.Reason
	c.Result = e.Result
	c.ReviewTime = e.ReviewTime

}
func (c collReview) ToDesc() creviewd.ReviewDesc {
	return creviewd.ReviewDesc{
		TargetType: c.TargetType,
		TargetID:   c.TargetID,
		Reviewer:   c.Reviewer,
		Reason:     c.Reason,
		Result:     c.Result,
		ReviewTime: c.ReviewTime,
	}
}

func (c collReview) ToAggregate() ddd.Aggregate {
	return c.ToReviewAggregate()
}
func (c collReview) ToReviewAggregate() *creviewd.ReviewAggregate {
	return &creviewd.ReviewAggregate{

		ReviewDesc: c.ToDesc(),
	}
}
